<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">


    <ui:define name="title">
        <h:outputText value="#{bundle.EditUserTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form styleClass="form">
            <p:fieldset legend="User Edit"  >
                <h:outputText value="#{userController.current.userLogin}" styleClass="engraved"/>
                <br/>
                <p:separator/>

                <c:choose>
                    <c:when test="#{userController.allowedGroups('2')}">
                        <p:commandButton ajax="false" action="#{userController.prepareList}" value="Show All" immediate="true"/>
                        <p:spacer width="10"/>
                    </c:when>
                </c:choose>
                <p:commandButton action="#{userController.update}" value="Update"  />
                <p:spacer width="10"/>
                <p:commandButton ajax="false" action="index" value="Cancel" immediate="true"/>
                <br/>
                <br />
                <h:panelGrid columns="2" columnClasses="label,field" styleClass="form_list">
                    <h:outputLabel value="#{bundle.EditUserLabel_userLogin}" for="userLogin" />
                    <p:inputText id="userLogin" label="User Login" value="#{userController.current.userLogin}" title="#{bundle.EditUserTitle_userLogin}" required="true" requiredMessage="#{bundle.EditUserRequiredMessage_userLogin}"/>
                    <h:outputLabel value="#{bundle.EditUserLabel_userEmail}" for="userEmail" />
                    <p:inputText id="userEmail" value="#{userController.current.userEmail}" title="#{bundle.EditUserTitle_userEmail}" required="true" requiredMessage="#{bundle.EditUserRequiredMessage_userEmail}"/>
                    <c:if test="#{userController.allowedGroups('2')}">
                        <h:outputLabel value="#{bundle.EditUserLabel_userLive}" />
                        <p:selectBooleanCheckbox value="#{userController.current.userLive}"/>
                        <p:spacer width="10"/>
                    </c:if>
                </h:panelGrid>
                <c:if test="#{userController.myselftEditing or userController.allowedGroups('2')}">
                    <p:commandButton id="basic" value="Reset Password" onclick="dlg2.show();" type="link" />
                    <h:outputLabel value="" />
                </c:if>

                <p:dialog widgetVar="dlg2" header="New Password">
                    <h:outputLabel value="#{bundle.CreateUserLabel_userPass}" for="userPass" />
                    <p:password redisplay="true" feedback="true"  id="userPass2" value="#{userController.current.userPass}" title="#{bundle.CreateUserTitle_userPass}" required="true" requiredMessage="#{bundle.CreateUserRequiredMessage_userPass}" styleClass="form"/>
                    <br/>
                    <p:spacer width="10"/>
                    <p:commandButton id="ok" value="Done" onclick="dlg2.hide();" type="link" />
                </p:dialog>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>

